using TUVienna.CS_CUP.Runtime;
using System.Collections.Generic;
using System;
using System.IO;

%%
%eof{

%eof}

%cup

%state TRACK
%state WPT
%state TRACKNAME
%state TIME

DIGIT=[0-9]+
ALPHA=[a-zA-Z]+
ALPHANUM=[0-9a-zA-Z]+
DECIMAL={DIGIT}*\.{DIGIT}+
 


%%

<YYINITIAL> "<gpx" {return new Symbol(sym.BGPX);}

<YYINITIAL> "<trk>" { yybegin(TRACK); return new Symbol(sym.BTRACK); } 

<YYINITIAL> "</gpx>" { return new Symbol(sym.EGPX);}

<TRACK> "<name>" { yybegin(TRACKNAME); return new Symbol(sym.BTRKNAME); }

<TRACK, YYINITIAL> "<wpt" {yybegin(WPT); return new Symbol(sym.BWPT);}

<TRACK, YYINITIAL> "<trkpt" {yybegin(WPT); return new Symbol(sym.BTRKPT);}

<TRACK> "</trk>" { yybegin(YYINITIAL); return new Symbol(sym.ETRACK);}

<TRACKNAME> [0-9a-zA-Z]+ { return (new Symbol(sym.TEXT,yytext()));}

<TRACKNAME> "</name>" { yybegin(TRACK); return new Symbol(sym.ETRKNAME); }

<WPT> [-0-9]*\.*[0-9]+ 	{ return new Symbol(sym.DECIMAL, yytext());} 

<WPT> "<ele>" { return new Symbol(sym.BELE);}

<WPT> [0-9]*\.[0-9]+ 	{return  new Symbol(sym.DECIMAL, yytext());}

<WPT> "</ele>" { return new Symbol(sym.EELE);}

<WPT> "</wpt>" { yybegin(YYINITIAL); return new Symbol(sym.EWPT); }

<WPT> "</trkpt>" { yybegin(TRACK); return new Symbol(sym.ETRKPT); }

<WPT> "<time>" { yybegin(TIME); return new Symbol(sym.BTIME);}

<TIME> [-:WTZ0-9]+ {return new Symbol(sym.TIME, yytext());}

<TIME> "</time>" { yybegin(WPT); return new Symbol(sym.ETIME);}

<YYINITIAL,TRACK,WPT,TRACKNAME,TIME> [ \t\n\f\r] { break; }

<YYINITIAL,TRACK,WPT,TRACKNAME,TIME> . { break;}